#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from flask import Flask

# Use flask_cors to make all routes support CORS
# The documentation of flask_cors is:
# https://flask-cors.readthedocs.io/en/latest/
from flask_cors import CORS as cors

app = Flask(__name__)
cors(app)

# "allenz" use port 5000.
# flask run -p 5000

# open index.html
with open('allenz\\index.html', mode = 'r', encoding='utf-8') as index:
    index_html = index.read()

@app.route('/')
def load_index():
    return index_html

# load JavaScript
with open('allenz\\public\\qq.js', mode = 'r', encoding='utf-8') as js:
    load_javascript = js.read()

@app.route('/qq.js')
def load_js():
    return load_javascript

# load friends
with open('allenz\\public\\friends.json', mode = 'r', encoding = 'utf-8') as friends:
    friends_list = friends.read()

@app.route("/friends.json")
def load_friends():
    return friends_list

if __name__ == "__main__":
    app.run(port = 5000)